Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API and caching #4

Merged
merged 3 commits into from
Oct 3, 2024
Merged

Add API and caching #4

merged 3 commits into from
Oct 3, 2024

Conversation

benoit74
Copy link
Contributor

@benoit74 benoit74 commented Oct 1, 2024

Changes:

  • retrieve page information from Deki API, using an authentication token retrieved from home page
    • from my experience, the token is valid for multiple days, no worries to have here
  • cache page and API responses on the file system so that one can re-use same JSON file over and over without having to worry

Nota: this is not yet used to populate anything in the ZIM, only "utility" code for now

To be reviewed after #3 is merged

@benoit74 benoit74 self-assigned this Oct 1, 2024
Copy link

codecov bot commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 17.85714% with 92 lines in your changes missing coverage. Please review.

Project coverage is 44.94%. Comparing base (8efbbe5) to head (40cb342).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
scraper/src/libretexts2zim/client.py 19.76% 69 Missing ⚠️
scraper/src/libretexts2zim/entrypoint.py 16.66% 10 Missing ⚠️
scraper/src/libretexts2zim/processor.py 11.11% 8 Missing ⚠️
scraper/src/libretexts2zim/__main__.py 0.00% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main       #4       +/-   ##
===========================================
- Coverage   56.72%   44.94%   -11.79%     
===========================================
  Files           7        7               
  Lines         238      336       +98     
  Branches       19       32       +13     
===========================================
+ Hits          135      151       +16     
- Misses        102      184       +82     
  Partials        1        1               

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benoit74 benoit74 force-pushed the add_api_and_caching branch 2 times, most recently from a04e45e to 9a30ccc Compare October 1, 2024 11:10
@benoit74 benoit74 marked this pull request as ready for review October 1, 2024 11:12
@benoit74 benoit74 requested a review from rgaudin October 1, 2024 11:12
@benoit74 benoit74 added this to the 0.1 milestone Oct 1, 2024
@rgaudin rgaudin changed the base branch from main to add_overwrite October 1, 2024 15:22
Copy link
Member

@rgaudin rgaudin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find we're duplicating the cache reading/writing bits ; maybe room for sharing this

Dockerfile Outdated Show resolved Hide resolved
scraper/src/libretexts2zim/client.py Outdated Show resolved Hide resolved
scraper/src/libretexts2zim/client.py Outdated Show resolved Hide resolved
scraper/src/libretexts2zim/entrypoint.py Outdated Show resolved Hide resolved
scraper/src/libretexts2zim/entrypoint.py Show resolved Hide resolved
scraper/src/libretexts2zim/generator.py Outdated Show resolved Hide resolved
@benoit74
Copy link
Contributor Author

benoit74 commented Oct 3, 2024

I find we're duplicating the cache reading/writing bits ; maybe room for sharing this

This is probably because some of the code was buggy ^^ I fixed this. There is indeed only small variations ... but pretty important ones.

@benoit74 benoit74 force-pushed the add_api_and_caching branch 3 times, most recently from 52ac5cf to 2def419 Compare October 3, 2024 13:59
@benoit74 benoit74 force-pushed the add_overwrite branch 2 times, most recently from a71de74 to a3cd390 Compare October 3, 2024 14:09
Base automatically changed from add_overwrite to main October 3, 2024 14:12
@benoit74
Copy link
Contributor Author

benoit74 commented Oct 3, 2024

I had to rebase to fix conflicts. Please review only two last commits which contains "real" modifications.

Nota: Iast commit is about making codecov informational. I find it's mostly mandatory since in scrapers like this one, most code is covered by integration tests, but these are not reported in codecov ...

@benoit74 benoit74 requested a review from rgaudin October 3, 2024 14:20
Dockerfile Show resolved Hide resolved
@benoit74 benoit74 merged commit e7a408c into main Oct 3, 2024
9 checks passed
@benoit74 benoit74 deleted the add_api_and_caching branch October 3, 2024 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants